package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.GoalSelfDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.GoalSelf;

public class GoalSelfDaoImpl extends BaseDaoImpl implements GoalSelfDao {

    public void insert(Object goalSelf) {
	sqlMapClientTemplate.insert("biz.insertGoalSelf", goalSelf);
    }

    public Object get(Long id) {
	return (GoalSelf) sqlMapClientTemplate.queryForObject("biz.getGoalSelfById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("biz.updateGoalSelf", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("biz.deleteGoalSelf", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalSelfDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findGoalSelfByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findGoalSelfByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalSelfDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findGoalSelfByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findGoalSelfByPage", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalSelfDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("biz.findAllGoalSelf");
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.GoalSelfDao#findAllGoalSelf(java.util.Map)
     */
    public List<GoalSelf> findAllGoalSelf(Map map) {
	return (List<GoalSelf>)getSqlMapClientTemplate().queryForList("biz.findGoalSelfForMap", map);
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.GoalSelfDao#getAllAuditGoalSelf(int, long)
     */
    public List<GoalSelf> getAllAuditGoalSelf(int year, long orgId) {
	Map map = new HashMap();
	map.put("year", year);
	map.put("orgId", orgId);
	map.put("auditResult", GoalSelf.AUDIT_YES);
	return findAllGoalSelf(map);
    }

}
